package com.wzh.glsc.search.controller;

import com.wzh.common.exception.BizCodeEnume;
import com.wzh.common.to.es.SkuEsModel;
import com.wzh.common.utils.R;
import com.wzh.glsc.search.service.ProductSaveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * @author xiaoming
 * @PackageName:com.wzh.glsc.search
 * @ClassName:@{NAME}
 * @Description:
 * @date:@{DATE}@{TIME}
 */
@Slf4j
@RestController
@RequestMapping("search/save")
public class ElasticSaveController {

    @Autowired
    private ProductSaveService productSaveService;

    @RequestMapping("/product/up")
    public R productStatusUp(@RequestBody List<SkuEsModel> skuEsModels){
        Boolean b=false;
        try {
            b=productSaveService.productStatusUp(skuEsModels);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return b?R.error(BizCodeEnume.UP_PRODUCT_EXCEPTION.getCode(),BizCodeEnume.UP_PRODUCT_EXCEPTION.getMsg() )
                :R.ok();
    }

}
